<template>
  <div v-show="dialogValue" class="add-form f-c" style="overflow: auto">
    <DataUploadFormAdd ref="DataUploadFormAddRef" @back="onPageBack" />
    <div class="header">
      <div class="title">
        历史上传记录
      </div>
    </div>
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="300px"
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
          <el-table-column label="操作" fixed="right" width="140px">
              <template slot-scope="scope">
                  <el-button
                      type="primary"
                      @click="onReadFile(scope.row)"
                  >查看附件</el-button>
              </template>
          </el-table-column>
      </el-table>
    </div>
    <el-dialog
      title="文件上传"
      :visible.sync="dialogValue2"
      width="800px"
      append-to-body
    >
      <DataUploadFormEdit ref="DataUploadFormEditRef" @back="dialogValue2 = false" />
    </el-dialog>
      <el-dialog
          title="附件"
          :visible.sync="dialogValue3"
          width="800px"
          append-to-body
      >
          <FileView v-if="fileList.length" :file-list="fileList" />
          <el-empty v-else></el-empty>
      </el-dialog>
  </div>
</template>

<script>
import { http } from '@/api'
import DataUploadFormAdd from '@/views/meeting/apply/data-upload-form-add'
import DataUploadFormEdit from '@/views/meeting/apply/data-upload-form-edit'
import crud from '@/mixins/crud'
import { getName, Investor, MeetingType } from '@/dict'
export default {
  name: 'DataUpload',
  components: { DataUploadFormAdd, DataUploadFormEdit },
  mixins: [crud],
    props: {
        currentDetail: Object
    },
  data() {
    return {
      dialogValue: false,
      dialogValue2: false,
        dialogValue3: false,
        fileList: [],
      columns: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'meetingTypeName', label: '会议类型' },
        { prop: 'createTime', label: '上传时间' }
      ],
      statusList: [
        { value: '1', name: '已通过' },
        { value: '2', name: '未通过' }
      ],
      tableData: [
      ]
    }
  },
  methods: {
    formatTableData(data) {
      data.forEach(el => {
        el.meetingTypeName = getName(el.meetingType, MeetingType)
        el.investorName = getName(el.investor, Investor)
        el.statusName = getName(el.status, this.statusList)
      })
    },
    open(item) {
        this.searchParams = {
            projectId: item.id
        }
      if (!this.request) {
        this.request = http.meeting_data
      }
      this.onSearch()
      this.$refs.DataUploadFormAddRef.open(item)
      this.dialogValue = true
    },
    onPageBack() {
      this.$emit('get-page')
      this.dialogValue = false
    },
    onEdit(row) {
      this.dialogValue2 = true
      this.$refs.DataUploadFormEditRef.open(row)
    },
      onReadFile(row) {
        http.meeting_data.fileList(row.id).then(res => {
            this.fileList = res.data
        })
          this.dialogValue3 = true
      }
  }
}
</script>

<style scoped lang="scss">
</style>
